﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <link href="../Frozenui1.3/css/frozen.css" rel="stylesheet" />
    <script src="../JS/layer/layer.m.js"></script>
    <script src="../JS/zepto.min.js"></script>
    <script src="../Frozenui1.3/js/frozen.js"></script>
    <script src="http://cdnjs.gtimg.com/cdnjs/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="../JS/Date/FT_Date.min.js"></script>
    <script src="../JS/zepto.min.js"></script>
    <script src="../JS/avalon.min.js"></script>
    <link href="../JS/Date/FT_Date.min.css" rel="stylesheet" />
    <script>
        var height = 0;
        var width = 0;
        var jq = $.noConflict();
        jq(function () {
            var currYear = (new Date()).getFullYear();
            var opt = {
                date: { preset: 'date' },
                defaultopi: {
                    theme: 'android-ics light', //皮肤样式
                    display: 'modal', //显示方式
                    mode: 'scroller', //日期选择模式
                    lang: 'zh',
                    startYear: currYear - 5, //开始年份
                    endYear: currYear + 5, //结束年份
                    onSelect: function (valueText, inst) {
                        //model.ctData.HDTime = valueText;
                    }
                }
            };
            jq("#kssj").scroller(jq.extend(opt['date'], opt['defaultopi'])).scroller('setDate', new Date(new Date().setDate(new Date().getDate() + 1)), true);
            jq("#jssj").scroller(jq.extend(opt['date'], opt['defaultopi'])).scroller('setDate', new Date(new Date().setDate(new Date().getDate() + 1)), true);
            model.ctData.StarTime = jq("#kssj").val();
            model.ctData.EndTime = jq("#jssj").val();
        })

        var model = avalon.define({
            $id: "qjmodel",
            ctData: { "LeiBie": "", "StarTime": "", "EndTime": "", "Daycount": 1, "ZhuYaoShiYou": "", "ChaoSongRen": "", "Files": "" },
            savedata: function () {
                var lg = $.loading({
                    content: '保存中...',
                })
                $.post("/API/WXAPI.ashx?Action=ADDCCQJ&r="+Math.random(), { "P1": JSON.stringify(model.ctData.$model) }, function (data) {
                    lg.hide();
                    var data = $.parseJSON(data);
                    if (data.ErrorMsg == "") {
                        $("button").hide();
                        var el = $.tips({
                            content: "保存成功！",
                            stayTime: 2000,
                            type: "success"
                        })
                        el.on("tips:hide", function () {
                            window.location.reload();
                        })
                    }
                    else {
                        $.tips({
                            content: "保存失败，原因：" + data.ErrorMsg,
                            stayTime: 2000,
                            type: "warn"
                        })
                    }
                })
            },
            repshow: function () {
                $(this).parent().siblings().removeClass("active");
                $(this).parent().addClass("active");
            },
            selperson: function () {
                $("#content").hide();
                $("#iframep").show();

                var cheight = height;
                var cwidth = document.documentElement.clientWidth - 5;

                $("#iframep").css("height", cheight);
                $("#iframep").css("width", cwidth);

            },
            bjk: function () {

                var tc = layer.open({
                    type: 1,
                    //content:$("#bmxx").html(),
                    //title: "活动简介",
                    content: '<div class="ui-form-item ui-form-item-textarea ui-border-b" style="width:' + (width - 76) + 'px;height:200px"><textarea id="hdjjbjk" style="padding-left: 0;height:170px;border: 1px solid #e0e0e0;" placeholder="请输入请假事由">' + model.ctData.ZhuYaoShiYou + '</textarea></div>',
                    btn: ['确认', '取消'],
                    shadeClose: false,
                    yes: function () {
                        model.ctData.ZhuYaoShiYou = $("#hdjjbjk").val();
                        if ($("#hdjjbjk").val() != "") {
                            $("#hdjj").removeClass("ui-txt-muted");
                            $("#hdjj").html($("#hdjjbjk").val());
                        }
                        else {
                            $("#hdjj").addClass("ui-txt-muted");
                            $("#hdjj").html("请输入请假事由");
                        }

                        layer.close(tc);

                    }, no: function () {
                    }
                })
            }

        });

        function goback() {
            $("#content").show();
            $("#iframep").hide();
        }
        function goconfirm(json) {
            if (json != null) {
                $("#kh_fzry").removeClass("ui-txt-muted");
                $("#kh_fzry").html(json.vuser);
                model.ctData.ChaoSongRen = json.vusername;
            }
            else {
                $("#kh_fzry").addClass("ui-txt-muted");
                $("#kh_fzry").html('请选择抄送人');
                model.ctData.ChaoSongRen = '';
            }

            $("#content").show();
            $("#iframep").hide();
        }

        avalon.ready(function () {
            width = document.documentElement.clientWidth;
            height = document.documentElement.clientHeight - 11;
            var lg = $.loading({
                content: '加载中...',
            })
            $.post("/API/WXAPI.ashx?Action=GETCOLUMNLIST&r="+Math.random(), { "P1": "3" }, function (data) {
                lg.hide();
                var data = $.parseJSON(data);
                if (data.ErrorMsg == "") {
                    $("select").empty();
                    for (var i = 0; i < data.Result.length; i++) {
                        $("select").append('<option value="' + data.Result[i].TypeNO + '">' + data.Result[i].TypeNO + '</option>');
                        if (i == 0) {
                            model.ctData.LeiBie = data.Result[i].TypeNO;
                        }
                    }
                }
                else {
                    $.tips({
                        content: "假别加载失败，原因：" + data.ErrorMsg,
                        stayTime: 2000,
                        type: "warn"
                    })
                }
            })
            $("#iframep").attr("src", "UI_PERSON.html?r=" + Math.random());
        })
    </script>
    <style type="text/css">
        .ui-select {
            border: none;
            border: 0;
            background-color: #fff;
            appearance: none;
            -moz-appearance: none; /* Firefox */
            -webkit-appearance: none; /* Safari 和 Chrome */
        }
    </style>
    <title>请假出差</title>
</head>
<body ms-controller="qjmodel">
    <div id="content">
        <div class="ui-footer ui-footer-stable ui-btn-group ui-border-t">
            <button class="ui-btn-lg ui-btn-primary" ms-click="savedata()">
                新增请假出差
            </button>
        </div>
        <section class="ui-container">
            <div class="ui-form ui-border-t">
                <div class="ui-form-item ui-border-b">
                    <label>
                        假别
                    </label>
                    <div class="ui-select ui-border-b">
                        <select ms-duplex="ctData.LeiBie"></select>
                    </div>
                </div>
                <div class="ui-form-item ui-border-b">
                    <label>
                        开始时间
                    </label>
                    <div class="ui-select ui-border-b">
                        <input type="text" placeholder="请输入开始时间" ms-duplex="ctData.StarTime" id="kssj" style="padding-left:0" />
                    </div>
                </div>
                <div class="ui-form-item ui-border-b">
                    <label>
                        结束时间
                    </label>
                    <div class="ui-select ui-border-b">
                        <input type="text" placeholder="请输入结束时间" ms-duplex="ctData.EndTime" id="jssj" style="padding-left:0" />
                    </div>
                </div>
                <div class="ui-form-item ui-border-b">
                    <label>
                        请假天数
                    </label>
                    <input type="text" placeholder="请输入请假天数" ms-duplex="ctData.Daycount" />
                </div>
                <div class="ui-form-item ui-border-b" style="height:auto;min-height:44px">
                    <label>
                        请假事由
                    </label>
                    <div class="ui-txt-muted ui-whitespace" style="padding-left: 95px;text-align:justify" id="hdjj" ms-click="bjk()">请输入请假事由</div>
                    <!--<input type="text" placeholder="请输入请假事由" ms-duplex="ctData.ZhuYaoShiYou" />-->
                </div>
                <div class="ui-form-item ui-border-b" style="height:auto">
                    <label>
                        抄送人
                    </label>
                    <div class="ui-txt-muted ui-whitespace" style="padding-left: 95px;text-align:justify" id="kh_fzry" ms-click="selperson()">请选择抄送人</div>

                </div>
                <div class="ui-form-item ui-border-b">
                    <label>
                        图片
                    </label>
                </div>
                <div class="ui-form-item ui-form-item-textarea ui-border-b">
                    <a class="ui-icon-add"></a>
                </div>
            </div>
        </section>
    </div>

    <iframe id="iframep" src="UI_PERSON.html" style="display:none"></iframe>
</body>
</html>
